package com.swan.controllers;

import java.io.IOException;

import com.swan.beans.UserInfo;
import com.swan.views.ClassMgtApplication;
import com.swan.views.ClassRegistrationApplication;
import com.swan.views.CourseSchedulingApplication;
import com.swan.views.LoginApplication;
import com.swan.views.SeasonMgtApplication;
import com.swan.views.UserMgtApplication;
import com.swan.views.StudentClassRegApplication;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.stage.Stage;

/**
 * MainController
 * 
 * @author xyh
 * @date 20230426
 *
 */

public class MainController {

	@FXML
	private Label UserInfoLabel;
	
	@FXML
	private Hyperlink logoutHyper;

	@FXML
	public void toUserMgt(ActionEvent event) throws IOException {
		UserMgtApplication app = new UserMgtApplication();
		app.showStage();
	}

	@FXML
	public void toSeasonMgt(ActionEvent event) throws IOException {
		SeasonMgtApplication app = new SeasonMgtApplication();
		app.showStage();
	}

	@FXML
	public void toClassMgt(ActionEvent event) throws IOException {
		ClassMgtApplication app = new ClassMgtApplication();
		app.showStage();
	}

	@FXML
	public void toCourseScheduling(ActionEvent event) throws IOException {
		CourseSchedulingApplication app = new CourseSchedulingApplication();
		app.showStage();
	}
	

	public void toStudentClassReg() throws IOException {
		StudentClassRegApplication app = new StudentClassRegApplication();
		app.showStage();
	}
	
	
	@FXML
	public void toClassRegistration(ActionEvent event) throws IOException {
		ClassRegistrationApplication app = new ClassRegistrationApplication();
		app.showStage();
	}
	
	@FXML
	public void toChangePwd(ActionEvent event) throws IOException {
		LoginApplication app = new LoginApplication();
		app.changePwd();
	}
	
	@FXML
	public void toLogout(ActionEvent event) throws IOException {
		UserInfo.cleanUserSession();
		Stage primaryStage = (Stage) logoutHyper.getScene().getWindow();
		primaryStage.close();
		LoginApplication app = new LoginApplication();
		app.login();
	}

	@FXML
	private void initialize() {
		UserInfoLabel.setText("Hi , " + UserInfo.getLoginUser().getUserName());
	}
}